﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FXnaAppBase
{
    [Serializable]
    public class BitmapCollection
    {

        [field:NonSerialized]
        public event EventHandler ImageAdded;

        [field: NonSerialized]
        public event EventHandler ImageRemoved;

        



        public BitmapCollection(CommonData parent)
        {

            this._parent = parent;

        }
        


        List<Bitmap> _images = new List<Bitmap>();

        public List<Bitmap> Images
        {
            get { return _images; }
           
        }


        CommonData _parent;

        public CommonData Parent
        {
            get { return _parent; }

        }


        public bool IsExist(string fname)
        {
            foreach (Bitmap item in this._images)
            {
                if (item.FileName==fname)
                {
                    return true;
                    
                }
                
            }

            return false;

        }



        public void AddImage(Bitmap image)
        {
            this._images.Add(image);

            if (ImageAdded!=null)
            {
                ImageAdded(image,EventArgs.Empty);

            }
 
        }

        public void RemoveImage(Bitmap image)
        {
            this._images.Remove(image);

            if (ImageRemoved!=null)
            {
                ImageRemoved(image, EventArgs.Empty);

            }
 
        }

    }
}
